Since most modern digital computers are transistor based, binary numbers have been traditionally used for internal computer processing. The binary number system, also known as radix-2, consists of just two unique numbers, 0 and 1, which conveniently represent the “off” and “on” states of a transistor element. In contrast, humans generally use decimal number system, also know as radix-10, which consists of numbers 0 through 9 coinciding with 10 fingers of two hands. To interact with a computer, decimal-based input data is converted to binary for computer processing. Thus, for example, when a calculation involves integers, a decimal number is represented as powers of 2 (i.e., 2n, . . . 24, 23, 22, 21, 20), whereby decimal 23 corresponds to binary 10111. When these calculations involve fractional numbers, the results are represented as sums of inverse powers of 2 (i.e., ½, ¼, ⅛, 1/16 . . . ½n), whereby one tenth ( 1/10) corresponds to a repeating binary fraction 0.00011 0011.
Due to design limitations, most modern computers cannot effectively represent repeating binary fractions. In particular, a typical computer system recognizes several native data types, including integer, single-precision floating point, double-precision floating point and character. One of the differences between these data types is the amount of memory allocated by the system to each data type. On a typical 32-bit system, characters are often stored in 8 bits, a short data type is 16 bits, integer and single-precision floating point numbers are 32 bits, and double-precision floating point numbers are 64 bits. As a result, due to the limited memory provided by a typical computer system for representation of data, a repeating binary fraction may be truncated and rounded off to fit into the available memory. This can lead to rounding errors that cause results calculated in radix-10 and those calculated in radix-2 to be different. The differences can easily escalate when many of such rounded-off numbers are multiplied or added resulting in significant discrepancies between the decimal and binary representations. This can be problematic in many applications, especially those dealing with monetary and monetary exchange calculations.
Some of these problems can be avoided if calculations are done by the computer in a radix-10 based number system. The two most popular approaches to the radix-10 computer arithmetic are large binary integers and small decimal digits techniques. The large binary integer solution requires writing software functions that allow calculation of large integers (e.g., 256 bit integers). Calculations can be done rapidly, but it can be very difficult to determine decimal point placement for addition and subtraction, because the number is in binary, but the decimal point needs to be placed between decimal digits. Therefore this approach is generally used for fixed point calculations (e.g., calculations where the decimal point is in a fixed location in the numbers to be processed). This approach ignores the decimal point in the calculation and simply implies it in the result. The only place where the decimal point is acknowledged is when a number needs to be displayed. This also requires that all calculations be done at the same precision in order to avoid the problem of aligning two binary numbers for a decimal operation, like addition.
Another approach is the small decimal digit approach which generally uses one-half to one byte (8 bits) to store a decimal digit. Thus, each decimal digit (0-9) is encoded by a corresponding four-bit binary number, so that a sequence of decimal digits can then be represented by concatenating the four-bit binary numbers. This makes placing the decimal point easier, but the calculation is much slower because each decimal digit is handled separately. In addition, there is a significant loss of storage efficiency because four bits can store decimal numbers 0-15 but are used in this approach to store only numbers 0-9. Furthermore, similar to the large binary integer approach, implementation details for the small decimal digit method differ significantly from processor-to-processor. This makes creating a platform-independent solution difficult.